﻿/*
* @Author： whg
* @Date : 2021-1-19
* @Desc : 
*/
using System.Collections;
using System.Collections.Generic;
using System.Text;
using UnityEngine;
using XNode;
public class SetNode : BaseNode 
{
    [Input(backingValue = ShowBackingValue.Always)]
    public BaseNode upLink;
    [Output(backingValue = ShowBackingValue.Always)]
    public BaseNode downLink;
    public override StringBuilder ToTable()
    {
        StringBuilder result = new StringBuilder(1024);
        string space = "				";
        result.Append(space + "{\n					type = Config.StoryConst." + setType + ",\n");
        space += "	";
        string Shortcut_str = "";
        switch (setType)
        {
            case SetType.ShortcutSetting:
                result.Append(space + "bool = " +short_bool.ToString().ToLower()+ ",\n");
                Dictionary<int, bool> temp = new Dictionary<int, bool>();
                shortcutTypeList.Sort();
                for (int i = 0; i < shortcutTypeList.Count; i++)
                {
                    int index = (int)shortcutTypeList[i];
                    if (index!=0&&!temp.ContainsKey(index))
                        Shortcut_str += index + ",";
                }
                result.Append(space + "content = {" + Shortcut_str + "},\n");
                if (short_extra != "")
                    result.Append(space + "{" + short_extra + "},");
                break;
            case SetType.IdleTime:
                 result.Append(space + "delay = "+Idle_delay + ",\n");
                break;
            case SetType.SetCameraRoot:
                result.Append(space + "wait = "+CamRoot_wait + ",\n");
                if (CamRoot_recover)
                {
                    result.Append(space + "recover = \"" + CamRoot_recover.ToString().ToLower() + "\",\n");
                }
                else
                {
                    result.Append(space + "ins_id = \"" + CamRoot_ins_id + "\",\n");
                    result.Append(space + "node = \"" + CamRoot_node + "\",\n");
                    result.Append(space + "rotate = {x=" + CamRoot_rotate.x + ",y=" + CamRoot_rotate.y + ",z=" + CamRoot_rotate.z + "},\n");
                    result.Append(space + "fov = " + CamRoot_fov + ",\n");
                }
                break;
            case SetType.UIEffect:
                result.Append(space + "content = \"" + uiEffect_content + "\",\n");
                result.Append(space + "pos = Vector3(" + uiEffect_pos.x+","+uiEffect_pos.y+","+uiEffect_pos.z + "),\n");
                result.Append(space + "scale = " + uiEffect_scale + ",\n");
                result.Append(space + "loop = " + uiEffect_loop.ToString().ToLower() + ",\n");
                if(uiEffect_last_time!=0)
                result.Append(space + "last_time = " + uiEffect_last_time + ",\n");
                break;
            case SetType.PlayBackgroundSound:
                 result.Append(space + "mode = LuaSoundManager.SOUND_TYPE." + bgSound_mode + ",\n");
                 result.Append(space + "content = \"" + bgSound_content + "\",\n");
                break;
            case SetType.PlaySoundEffect:
                result.Append(space + "delay_time = " + soundEffect_delay_time + ",\n");
                result.Append(space + "content = \"" + sound_content + "\",\n");
                result.Append(space + "loop = " + soundEffect_loop .ToString().ToLower()+ ",\n");
                break;
            case SetType.SetMapDynamic:
                result.Append(space + "width = " + mapDynamic_width + ",\n");
                result.Append(space + "height = " + mapDynamic_height + ",\n");
                break;
            case SetType.SetDynamicArea:
                result.Append(space + "target = " + dynamicArea_target + ",\n");
                result.Append(space + "content = AreaDataIndex." + dynamicArea_index + ",\n");
                break;
            case SetType.SetAnimatorSpeed:
                result.Append(space + "target = \"" + animatSpeed_target + "\",\n");
                result.Append(space + "ins_id = \"" + animatSpeed_ins_id + "\",\n");
                result.Append(space + "speed = \"" + animatSpeed_speed + "\",\n");
                break;
            case SetType.SetTimeScale:
                result.Append(space + "mode = \"" + (int)timeScale_mode + "\",\n");
                result.Append(space + "time = \"" + timeScale_time + "\",\n");
                result.Append(space + "target = \"" + timeScale_target + "\",\n");
                break;
            case SetType.SetSceneFog:
                result.Append(space + "start_dis = \"" + sceneFog_start_dis + "\",\n");
                result.Append(space + "end_dis = \"" + sceneFog_end_dis + "\",\n");
                break;
        }
        result.Append("				},");
        if (setType == SetType.ShortcutSetting && Shortcut_str == "")
            result.Clear();
        return result;
    }
    //ScreenEffect屏幕过渡效果,
    public enum SetType { ShortcutSetting, IdleTime, Handle3DCamera, SetCameraRoot, UIEffect, PlayBackgroundSound, PlaySoundEffect, SetMapDynamic, SetDynamicArea, SetAnimatorSpeed, SetTimeScale, SetSceneFog }
    //public enum SetType { 快捷设置, 间歇时间, 处理3D相机, 设置相机节点, 屏幕过渡效果, 播放UI特效, 背景音乐, 播放音效, 场景加载范围, 场景动态障碍区域, 设置动画速度, 设置慢放, 场景雾化效果 }
   [Tooltip("快捷设置, 间歇时间, 处理3D相机, 设置相机节点, 播放UI特效, 背景音乐, 播放音效, 场景加载范围, 场景动态障碍区域, 设置动画速度, 设置慢放, 场景雾化效果 ")]
    public SetType setType = SetType.ShortcutSetting;
    public enum ShortcutSetType { 主界面=1, 屏蔽技能按钮, 屏蔽摇杆按钮, 屏蔽除UI层外所有UI, 显示跳过按钮, 全屏遮罩, 屏蔽伤害飘字, 停止自动战斗=11, 停止自动任务, 屏蔽坐骑, 屏蔽相机更新, 开启场景精细加载 ,屏蔽位置同步,屏蔽主角动作,屏蔽场景对象NPC和玩家和怪物,屏蔽场景特效,屏蔽Fog,屏蔽所有怪物 ,屏蔽他人 ,屏蔽NPC,结束剧情时开始自动寻路仅副本中使用=997,结束剧情时开启自动战斗,结束剧情时开启自动任务}
    #region ShortcutSetting
    [Tooltip("快捷配置,可选择多个")]
    public List<ShortcutSetType> shortcutTypeList = new List<ShortcutSetType>() { new ShortcutSetType()};
     [Tooltip("true 设置  false 取消")]
    public bool short_bool = true;
    public string short_extra = "";
    #endregion

    #region IdleTime
    [Tooltip("间歇时间")]
    public float Idle_delay = 1;
    #endregion

    #region SetCameraRoot
      [Tooltip("是否还原")]
    public bool CamRoot_recover = false;
    [Tooltip("等待当前项执行完才进行下一项: wait = true\n当为false时，将会在一帧中继续执行下一片段")]
    public bool CamRoot_wait = false;
    [Tooltip("实例id")]
    public string CamRoot_ins_id = "huaxiangyi";
     [Tooltip("相机节点")]
    public string CamRoot_node = "sxj";
     [Tooltip("相机旋转角度")]
    public Vector3 CamRoot_rotate = new Vector3 (0,180,0);
     [Tooltip("相机范围角度")]
    public int CamRoot_fov = 54;
    #endregion

    #region ScreenEffect
    //type=Config.StoryConst.ScreenEffect,
    //                mode=1,
    //                time=1,
    #endregion

    #region UIEffect
    [Tooltip("特效名字")]
    public string uiEffect_content = "ui_bossname_anyiemo";
    [Tooltip("特效位置")]
    public Vector3 uiEffect_pos;
    [Tooltip("特效大小")]
    public float uiEffect_scale = 1;
    [Tooltip("特效循环播放")]
    public bool uiEffect_loop = false;
    [Tooltip("特效时间")]
    public float uiEffect_last_time = 0;
    #endregion

    #region  PlayBackgroundSound
    public enum BGSoundType{OPEN = 1,SWITCH }
    [Tooltip("背景音乐模式")]
    public BGSoundType bgSound_mode= BGSoundType.OPEN;
    [Tooltip("背景音乐名字")]
    public string bgSound_content = "city";
    #endregion

    #region   PlaySoundEffect
    [Tooltip("声音延迟时间")]
    public float soundEffect_delay_time = 1;
    [Tooltip("声音名字")]
    public string sound_content = "story01_jump01";
    [Tooltip("声音是否循环")]
    public bool soundEffect_loop = false;
    #endregion

    #region  SetMapDynamic
    [Tooltip("像素单位")]
    public int mapDynamic_width = 10000;
    [Tooltip("像素单位")]
    public int mapDynamic_height = 10000;
    #endregion

    #region SetDynamicArea
    public enum ServerArea {WalkType= 0,BlockType=1,SafeType=5}
    [Tooltip("动态障碍区id")]
    public int dynamicArea_target = 10021;
    [Tooltip("动态区索引")]
    public ServerArea dynamicArea_index = ServerArea.WalkType;
    #endregion
   
    #region  SetAnimatorSpeed
    [Tooltip("动画目标名字")]
    public string animatSpeed_target = "GameObject";
    [Tooltip("动画实例id")]
    public string animatSpeed_ins_id = "tiaochuan";
    [Tooltip("动画速度")]
    public float animatSpeed_speed = 1;
    #endregion

    #region  SetTimeScale
    public enum TimeScale{直接设置  = 0, 逐渐变化 }
    [Tooltip("变化模式")]
    public TimeScale timeScale_mode = TimeScale.直接设置;
    [Tooltip("变化时间")]
    public float timeScale_time = 2;
    [Tooltip("变化目标")]
    public float timeScale_target=0.5f;
    #endregion

    #region SetSceneFog
     [Tooltip("雾化开始距离")]
    public int sceneFog_start_dis = 20;
    [Tooltip("雾化结束距离")]
    public int sceneFog_end_dis = 80;
    #endregion
}
